package com.mcc.app.carbonEmission.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.carbonEmission.domain.ReportUploadInfo;
import com.mcc.app.carbonEmission.service.IReportUploadInfoService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 文件上传信息
 *
 * @author gxy
 * @date 2025-07-08
 */
@Api(tags = "文件上传信息")
@RestController
@RequestMapping("/carbonEmission/uploadInfo")
public class ReportUploadInfoController extends BaseController {

    @Autowired
    private IReportUploadInfoService reportUploadInfoService;

    @ApiOperation("查询文件上传信息列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<ReportUploadInfo>> list(ReportUploadInfo reportUploadInfo) {
        List<ReportUploadInfo> list = reportUploadInfoService.selectReportUploadInfoList(reportUploadInfo);
        return getDataTable(list);
    }

    @ApiOperation("查询文件上传信息列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<ReportUploadInfo>> page(ReportUploadInfo reportUploadInfo) {
        startPage();
        List<ReportUploadInfo> list = reportUploadInfoService.selectReportUploadInfoList(reportUploadInfo);
        return getDataTable(list);
    }

    @ApiOperation("获取文件上传信息详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<ReportUploadInfo> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(reportUploadInfoService.selectReportUploadInfoById(id));
    }

    @ApiOperation("新增文件上传信息")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:add')")
    @Log(title = "文件上传信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ReportUploadInfo reportUploadInfo) {
        reportUploadInfo.setUpDate(new Date());
        return toAjax(reportUploadInfoService.insertReportUploadInfo(reportUploadInfo));
    }

    @ApiOperation("修改文件上传信息")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:edit')")
    @Log(title = "文件上传信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ReportUploadInfo reportUploadInfo) {
        return toAjax(reportUploadInfoService.updateReportUploadInfo(reportUploadInfo));
    }

    @ApiOperation("删除文件上传信息")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('carbonEmission:uploadInfo:remove')")
    @Log(title = "文件上传信息", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(reportUploadInfoService.deleteReportUploadInfoByIds(ids));
    }
}
